/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1637203649616_6858';

  // add your middleware config here
  config.middleware = [ 'errorHandler', 'auth', 'jwtErr' ];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  config.security = {
    csrf: {
      ignore: ctx => { return ctx.ip === '127.0.0.1'; },
    },
  };

  config.jwt = {
    secret: '后台管理',
  };

  config.validate = {
    convert: true,
  };

  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    database: 'mall_development',
    username: 'root',
    password: 'root',
  };

  // 文件上传
  config.multipart = {
    fileSize: '30mb',
  };

  // 模板引擎
  config.view = {
    defaultViewEngine: 'nunjucks',
    defaultExtension: '.nj',
    mapping: {
      '.nj': 'nunjucks',
    },
  };

  return {
    ...config,
    ...userConfig,
  };
};
